import Cookies from 'js-cookie'

const state = {
  regionid: null,
  lineId: 0,
  title: ''
}

const mutations = {
  CHANGE_PROCESS: (state, regionid) => {
    state.regionid = regionid
  },
  CHANGE_LINE: (state, lineId) => {
    state.lineId = lineId
  },
  CHANGE_TITLE: (state, title) => {
    state.title = title
  }
}

const actions = {
  changeProcess({ commit }, regionid) {
    // *** 当前点击的制程id存一份在Cookies中，因为vuex数据会在f5刷新后丢失
    Cookies.set('currentReginid', regionid)
    commit('CHANGE_PROCESS', regionid)
  },
  changeLine({ commit }, lineId) {
    Cookies.set('currentLineId', lineId)
    commit('CHANGE_LINE', lineId)
  },
  changeTitle({ commit }, title) {
    Cookies.set('currentTitle', title)
    commit('CHANGE_TITLE', title)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

